#include"tcp_client.hpp"

int main(int argc,char* argv[])
{
    if(argc!=3){
        std::cout<<"Usage: ./client server_ip server_port\n";
        return 1;
    }
    std::string server_ip=argv[1];
    u_int16_t server_port=atoi(argv[2]);
    struct sockaddr_in addr;
    TcpClient client(server_ip,server_port);
    bool ret=client.Connect();
    if(!ret){
        return 1;
    }

    for(;;){
        std::cout<<"请输入你要查找的单词：";
        std::string req;
        std::cin>>req;
        if(!std::cin){
            break;
        }
        client.Send(req);
        std::string resp;
        client.Recv(&resp);
        std::cout<<resp<<std::endl;
    }
    return 0;
}